package com.wkhyapp.lm.contract;

import com.wkhyapp.lm.base.BasePresenter;
import com.wkhyapp.lm.http.ApiCallback;
import com.wkhyapp.lm.http.net.BaseRequest;
import com.wkhyapp.lm.http.net.CreateVirtualRequest;
import com.wkhyapp.lm.http.net.SuperResponse;
import com.wkhyapp.lm.utils.MemberUtils;

/**
 * Created by fang on 2021/11/25.
 */

public class AddXNPresenter extends BasePresenter<AddXNView> {


    public AddXNPresenter(AddXNView addXNView) {
        super(addXNView);
    }


    public void  upload(CreateVirtualRequest request){
        addSubscription(apiStores.createVirtual(request),new ApiCallback<SuperResponse<String>>() {
            @Override
            public void onSuccess(SuperResponse<String> response) {
                mvpView.updateSucc();
            }
            @Override
            public void onFailure(String msg) {
                mvpView.dismissLoad();
            }

            @Override
            public void onFinish() {
            }
        });
    }

    public void  getToken(){
        BaseRequest request = new BaseRequest();
        request.setUserId(MemberUtils.getUid());
        addSubscription(apiStores.getUploadToken(request),new ApiCallback<SuperResponse<String>>() {
            @Override
            public void onSuccess(SuperResponse<String> response) {
                mvpView.setToken(response.getItem());
            }
            @Override
            public void onFailure(String msg) {
                mvpView.dismissLoad();
            }

            @Override
            public void onFinish() {
            }
        });
    }
}
